#pragma once

#define INITGUID

#include "EnginePointer.h"
#include "EngineObject.h"
#include "d3dx10.h"
#include "IEngineComponent.h"
#include "ISerializerWriteContext.h"
#include "ISerializerReadContext.h"

#pragma comment(linker, "/INCLUDE:??0SpotLightComponent@@QAE@XZ")

// {A3313CB2-EEE6-4baa-873B-80D5BD1BA0B7}
DEFINE_GUID(SPOT_LIGHT_COMPONENT_GUID, 
0xa3313cb2, 0xeee6, 0x4baa, 0x87, 0x3b, 0x80, 0xd5, 0xbd, 0x1b, 0xa0, 0xb7);

class SpotLightComponent : public IEngineComponent
{
public:
	SpotLightComponent();
	SpotLightComponent(D3DXVECTOR3 position, D3DXVECTOR3 color, float radius, float angle, float decayExponent, D3DXVECTOR3 lookAt);
	~SpotLightComponent(void);

	GUID getSystemIdentifier();
	GUID getComponentIdentifier();
	D3DXVECTOR3 getPosition();
	void setPosition(D3DXVECTOR3 position);
	D3DXVECTOR3 getColor();
	void setColor(D3DXVECTOR3 color);
	float getRadius();
	void setRadius(float radius);
	float getAngle();
	void setAngle(float angle);
	float getDecayExponent();
	void setDecayExponent(float decayExponent);
	D3DXVECTOR3 getLookAt();
	void setLookAt(D3DXVECTOR3 lookAt);
	D3DXMATRIX getWorld();
	float getAngleCosine();
	D3DXVECTOR3 getNormalLookAt();
	
	void Serialize(EnginePointer<ISerializerWriteContext>& context, char* name);
	static IEngineComponent* Deserialize(EnginePointer<ISerializerReadContext>& context);

	AUTO_SIZE;
private:
	D3DXVECTOR3 position;
	D3DXVECTOR3 color;
	float radius;
	float angle;
	float decayExponent;
	D3DXVECTOR3 lookAt;
};